﻿package org.ccams.dao;

import java.util.List;

import org.ccams.domain.TpOutDetail;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class TpOutDetailDAO extends SqlMapClientDaoSupport{

	/**
	 * 返回所有记录
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TpOutDetail> getTpOutDetailAll(){		
		return getSqlMapClientTemplate().queryForList("tp_out_detail.getTpoutdetailAll");
	}
	/**
	 * 根据ID返回记录
	 * @param id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TpOutDetail> getTpoutdetailById(Long num){		
		return getSqlMapClientTemplate().queryForList("tp_out_detail.getTpoutdetailById",num);
	}
	/**
	 * 根据Num和Ord返回具体的明细记录
	 * @param tod
	 * @return
	 */
	public  TpOutDetail getTpoutdetailByNumAndOrd(TpOutDetail tod){		
		return (TpOutDetail)getSqlMapClientTemplate().queryForObject("tp_out_detail.getTpoutdetailByNumAndOrd",tod);
	}
	/**
	 * 返回记录行数
	 * @return
	 */
	public Integer getCount(){
		return (Integer)getSqlMapClientTemplate().queryForObject("tp_out_detail.getTpoutdetailCount");
	}
	/**
	 * 插入数据
	 * @param tod
	 * @return
	 */
	public int insertTpoutdetail(TpOutDetail tod) {
		return getSqlMapClientTemplate().update("tp_out_detail.insertTpoutdetail",tod);
	}
	/**
	 * 取得最新插入的数据行的ord
	 * @return
	 */
	public Integer getNewOrd(Long num){
		try{
			return (Integer)getSqlMapClientTemplate().queryForObject("tp_out_detail.getNewOrd",num)+1;
		}catch(NullPointerException e){
			e.printStackTrace();
			return 0;
		}
	}
	/**
	 * 更新数据
	 * @param tod
	 * @return
	 */
	public int updateTpoutdetail(TpOutDetail tod){
		return getSqlMapClientTemplate().update("tp_out_detail.updateTpoutdetail",tod);
	}
	/**
	 * 删除数据
	 * @param tod
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public int deleteTpoutdetail(TpOutDetail tod){
		return getSqlMapClientTemplate().delete("tp_out_detail.deleteTpoutdetail",tod);
	}
	/**
	 * 更新审核
	 * @param tod
	 * @return
	 */
	public int updateCommit(TpOutDetail tod){
		return getSqlMapClientTemplate().update("tp_out_detail.updateCommit",tod);
	}

}
